<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tjsinfo.tjsoa.addresslist.vo.AddresslistSend"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
  	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	
	<script type='text/javascript' src='<%=basePath%>dwr/interface/AddressListGroupBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	<style type="text/css">
			td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
         .trBgColor { background-color:#A4D7E8; cursor: hand;}
		.GroupIndexDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.black_overlays{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
	</style>
                
	<%
		List<AddresslistSend> list = (List<AddresslistSend>)request.getAttribute("list");
		String sendUsersId = (String)request.getAttribute("sendUsersId");
		Integer userid = (Integer)request.getAttribute("userid");
		String messageid = (String)request.getAttribute("messageid");
		
		String copyids = (String)request.getAttribute("copyids");
		int pagecount = 0;
		if(list.size() != 0){
			pagecount = list.size();
		}
		String listUser_id = (String)request.getAttribute("listUser_id");
		if(listUser_id == null)listUser_id = "-1";
	 %>
	 <script language="JavaScript" type="text/javascript" >//最大数据量
	 	window.onload = function(){initpage(1);}
var total="<%=pagecount %>";
//每页的显示量
var pagesize="17";
//一共有多少页
var pagenum=Math.ceil(total/pagesize);
//生成导航
var nowpage = 1;
function initpage(nowpage){
var pagenav='<a>共'+total+'条,共'+pagenum+'页&nbsp;&nbsp;当前为'+nowpage+'页</a>&nbsp;&nbsp; <a>跳转到';
pagenav += '<select onchange="goToPage(this.value);">';
for(i=1;i<=pagenum;i++){
	if(i==nowpage){
		pagenav += '<option value="'+i+'" selected="selected">'+i+'</option>';
	}else{
		pagenav += '<option value="'+i+'">'+i+'</option>';
	}
}
pagenav += '</select>页</a>';
if(pagenum != 0){
document.getElementById('page').innerHTML=pagenav;
}
}
//翻页
function goToPage(page){
var start=(page-1)*pagesize;
var max=page*pagesize;
for(vs=0;vs<total;vs++){
var obj=document.getElementById('item_' + vs);
obj.style.display="none";
}
if(max>total)max=total;
for(v=start;v<max;v++){
var obj=document.getElementById('item_' + v);
obj.style.display="block";
}
initpage(page);
}
//上一页
function up(nowpage){
if(nowpage>1)goToPage((nowpage-1));
}
//下一页
function down(nowpage){
if(nowpage<pagenum)goToPage((nowpage+1));
}
</script>
<script type="text/javascript">
	function xianshiGroup(){
		document.getElementById("GroupIndexDiv").style.top = document.body.clientHeight/5;
		document.getElementById("GroupIndexDiv").style.left = document.body.clientWidth/6;
		AddressListGroupBo.getGroup(<%=userid %>,"1",GroupName);
	}
		
	function xiaoshiGroup(){
		document.getElementById("GroupIndexDiv").style.display = "none";
		document.getElementById("blackdiv").style.display = "none";
	}
		
	function GroupName(fu){
		var Group = '<table width="100%" class="researchtab"><tr>';
		var i = 0;
		for(var a=0;a<fu.length;a=a+3){
			if(fu[a+1].length>=10){
				if(fu[a+1] == '我的联系人'){
					document.getElementById("groupid").value = fu[a];
					Group += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" checked="checked" onclick="fuzhi('+fu[a]+')"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,10)+'</a></td>';
				}else{
					Group += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'"/><a title=\"'+fu[a+1]+'\" onclick="fuzhi(\''+fu[a]+'\')">'+fu[a+1].substring(0,10)+'</a></td>';
				}
			}else{
				Group += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" onclick="fuzhi(\''+fu[a]+'\')"/>'+fu[a+1]+'</td>';
			}
			i++;
			if(i%3 == 0){
				Group += '</tr><tr>';
			}else if(a == fu.length-1){
				Group += '</tr>';
			}
		}
		var GroupDiv = document.getElementById("GroupDiv");
		GroupDiv.innerHTML = Group;
		if(fu.length>0){
			document.getElementById("blackdiv").style.display = "block";
			document.getElementById("GroupIndexDiv").style.display = "block";
		}else{
			Ext.MessageBox.alert('提示框','<nobr>请返回通讯录模块中新增一个组，用于接收联系人</nobr>');
		}
	}
	
	function submitform1(str){
		document.getElementById("returnType").value = str;
		if(str == 'yes'){
			if(document.getElementById("groupid").value != null && document.getElementById("groupid").value != ''){
				document.form1.submit();
			}else{
				Ext.MessageBox.alert('提示框','<nobr>请选择联系人所在组</nobr>');		
			}
		}else{
			document.form1.submit();
		}
	}
	
	function fuzhi(str){
		document.getElementById("groupid").value = str;
	}
	
	function guanbi(){
		window.close();
	}
	
	window.onload = function(){
		initpage(1);
		var tb = new Ext.Toolbar(
			{
				height:25
			}
		);
	
	    tb.render('menu');
	    tb.add(
	    {
	            text:'接受',
	            iconCls: 'daohang',
	        	handler: function(){
	        		xianshiGroup();
				}
	    },
	    {
	            text:'拒绝',
	            iconCls: 'daohang',
	        	handler: function(){
	        		submitform1('no');
				}
	    },
	    {
	            text:'返回',
	            iconCls: 'daohang',
	        	handler: function(){
	        		history.go(-1);
				}
	    }
	    );
		tb.addFill();
	    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">接收发送联系人信息</a>&nbsp;&nbsp;&nbsp;');
	}
</script>
  </head>
  
  <body>
  <div id="right" style="z-index: 19;height: 98%;width: 99%">
      <div id="menu" style="padding-top:4px;"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
      	<tr>
            <td width="100%" valign="top" height="100%">
               <div class="contab" style="height: 90%;width: 100%;margin-left: 0px;" >
                  <table class="p_06" width="100%" border="0" cellspacing="0" id="mytable">
                    <tr>
                        <th width="8%">姓名</th>
                        <th width="12%">手机</th>
                        <th width="36%">单位</th>
                        <th width="10%">部门</th>
                        <th width="13%">单位电话</th>
                    </tr>
                    <%
                    	int i = 0;
                    	for (AddresslistSend listUser : list) {
                    	String id = listUser.getId().toString();
                    	String userName = listUser.getAddressListUser().getUserName();
                    	String userName1 = userName;
                    	if(userName != null && !"".equals(userName)){
                    		if(userName.length()>4)userName=userName.substring(0,4);
                    	}
                    	String mobile = listUser.getAddressListUser().getMobile();
                    	String mobile1 = mobile;
                    	if(mobile != null && !"".equals(mobile)){
                    	if(mobile.length()>11)mobile=mobile.substring(0,11);
                    	}
                    	String company = listUser.getAddressListUser().getCompany();
                    	String company1 = company;
                    	if(company != null && !"".equals(company)){
                    	if(company.length()>24)company=company.substring(0,24);
                    	}
                    	String sector = listUser.getAddressListUser().getSector();
                    	String sector1 = sector;
                    	if(sector != null && !"".equals(sector)){
                    	if(sector.length()>6)sector=sector.substring(0,6);
                    	}
                    	String companyPhone = listUser.getAddressListUser().getCompanyPhone();
                    	String companyPhone1 = companyPhone;
                    	if(companyPhone != null && !"".equals(companyPhone)){
                    	if(companyPhone.length()>12)companyPhone=companyPhone.substring(0,12);
                    	}
                    	if(listUser_id.equals(id)){
					%>
					<tr class="trBgColor" id="item_<%=i %>">
					<%
						}else{
					%>
					<tr onmouseover='this.className="trBgColor"' onmouseout='this.className=""' id="item_<%=i %>">
					<%
						}
					 %>
						<td><a title="<%=userName1 %>"><%=userName %></a></td>
						<td><a title="<%=mobile1 %>"><%=mobile %></a></td>
						<td><a title="<%=company1 %>"><%=company %></a></td>
						<td><a title="<%=sector1 %>"><%=sector %></a></td>
						<td><a title="<%=companyPhone1 %>"><%=companyPhone %></a></td>
					</tr>
					<%
						i++;
						}
                     %>
                      <tr align="center">
                        <td colspan="5">
                          <div class="pages" id="page">
                          </div>
                        </td>
                    </tr>
                 </table>
              </div>
            </td>
          </tr>
      </table>
     </div>

<div id="blackdiv" class="black_overlays">
	<iframe style="width:100%;height:100%;filter:alpha(opacity=0);-moz-opacity:0"></iframe>
</div>
<div id="GroupIndexDiv" class="GroupIndexDiv">
    <table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td background="<%=basePath%>images/small_07.gif" height="24" align="left">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="8%" style="padding-left:15px; padding-top:3px;"><img src="<%=basePath%>images/icon_07.gif" /></td>
                        <td width="86%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">接收联系人组</td>
                        <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiDeleteGroup();"
											style="cursor: hand" />
							</div>
						</td>
                      </tr>
                    </table>
                 </td>
               </tr>
               <tr>
                 <td align="center" class="zz">
                     <table width="90%" height="180" border="0" cellspacing="0" cellpadding="0">
                      <tr><td colspan="3" align="left">
                       <div id="GroupDiv"></div>
                      </td>
                      </tr>
                      <tr><td colspan="3" style="border-top:1px #CFCFD1 solid">&nbsp;</td></tr>
                      <tr>
                        <td colspan="3" align="center"><a href="javaScript:submitform1('yes');"><img src="<%=basePath%>images/qd.gif" /></a>&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiGroup();"><img src="<%=basePath%>images/qx.gif" />
                        </td>
                       </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                     </tr>
                    </table>
                 </td>
               </tr>
             </table>
</div>
<form action="<%=basePath %>tjsinfo/tjsoa/addresslist/returnSendAddressListUser.do" name="form1" method="post">
	<input type="hidden" name="sendUsersId" value="<%=sendUsersId %>">
	<input type="hidden" name="groupid"/>
	<input type="hidden" name="returnType"/>
	<input type="hidden" name="copyids" value="<%=copyids %>"/>
	<input type="hidden" name="userid" value="<%=userid %>"/>
	<input type="hidden" name="messageid" value="<%=messageid %>"/>
</form>
  </body>
  <script>
for(vs=1;vs<total;vs++){
	var obj=document.getElementById('item_' + vs);
	obj.style.display="none";
	for(v=1;v<pagesize;v++){
		if(vs==v){
			var obj=document.getElementById('item_' + vs);
			obj.style.display="block";
		}
	}
}
</script>
</html>
